<!--
	作者：2575202388@qq.com
	时间：2019年8月6日17:11:53
	描述：书籍管理-题目管理
-->

<template>
	<Modal title="题目管理" v-model="modal0" width="1200px" footer-hide @onCancel="closemodel">
		<div style="width:100%;">
			<div style="background: #fff;">
				<div style="width:100%;float:left;padding-top:5px;padding-bottom: 10px;">
					<div style="width:50%;text-align: left;float:left;">
						<Button v-on:click="addtm()" icon="md-add" type="primary" style="background-color: #3fc1c9;border:1px solid #3fc1c9;">添加题目</Button>
						<Button v-on:click="importTm()" icon="md-cloud-upload" type="primary" style="background-color: #8B8378;border:1px solid #8B8378;">导入题目</Button>
					</div>
				</div>
			</div>
			<add ref="add" v-on:reload="search()" :bid="bid"></add>
			<ss :tj="tj" ref="bookquestionss"></ss>
		</div>
		<importtm ref="importtm" v-on:reload="search()" :bid="bid"></importtm>
	</Modal>
</template>

<script>
	import ss from "./ss";
	import importtm from "./import";
	import add from "./add";
	export default {
		name: "bookquestion",
		props: {
    		bid:{
    			type: String
    		},
			recommendorid:{
				type: String,
				default: function() {
					return ""
				}
			}
    	},
		data() {
			return {
				tj: {
					bid:'',//书籍id	
				},
				modal0:false
			}
		},
		methods: {
			addtm(){
				if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin' || this.recommendorid==this.user.usid){
					this.$refs.add.openmodal();
				}else{
					this.$Modal.error({
					    title: "提示",
					    content:'对不起，您没有此权限！'
					});
				}
			},
			search(){
				this.$refs.bookquestionss.load();
			}, 
			importTm(){
				if((this.user.permission && this.user.permission.indexOf("1")>-1) || this.user.uname=='admin' || this.recommendorid==this.user.usid){
					this.$refs.importtm.modal0=true;
				}else{
					this.$Modal.error({
					    title: "提示",
					    content:'对不起，您没有此权限！'
					});
				}	
			}, 
			closemodel(){
				this.modal0=false;
			}
		},
		components: {
			ss,
			importtm,
			add
		},
		mounted(){
		},
		watch:{
			modal0(news,olds){
				if(!news){
					this.tj.bid="";
				}else{
					this.tj.bid=this.bid;
				}
			}
		},
		computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		}
	}
</script>

<style>
</style>